/**
 * @author [siwi]
 * @email [siwi@siwi.me]
 * @create date 2017-08-29 09:03:11
 * @modify date 2017-08-29 09:03:11
 * @desc [description]
*/

const User = require('../../Mongoose/User')

class Index {
    constructor() {

    }
    // GET 索引列表
    async index (ctx, next) {
        let data = {
            _id: ctx.user.user_id
        }
        let res = await User.find(data)
        
        return ctx.body = res
    }
    // GET 创建显示表单
    async create (ctx, next) {
        let data= {
            action: 'create'
        }
        return ctx.body = data
    }
    //POST 保存创建的数据
    async store (ctx, next) {
        let data = {
            username: ctx.request.body.username,
            password: ctx.request.body.password,
            display_name: ctx.request.body.display_name,
            email: ctx.request.body.email,
            phone: ctx.request.body.phone,
            gender: ctx.request.body.gender
        }

        let res = await User.create(data)

        return ctx.body = res
    }
    //GET 显示对应id的内容
    async show (ctx, next) {
        let data= {
            action: 'show',
            id: ctx.params.id            
        }
        
        return ctx.body = data
    }
    //GET 编辑（显示表单）
    async edit (ctx, next) {
        let data= {
            action: 'edit',
            id: ctx.params.id          
        }
        
        return ctx.body = data
    }
    // PUT/PATCH保存
    async save (ctx, next) {
        let data= {
            action: 'save',
            id: this.params.id            
        }
        
        return ctx.body = data
    }
    // GET 删除
    async destroy (ctx, next) {
        let data= {
            action: 'destroy',
            id: this.params.id            
        }
        
        return ctx.body = data
    }
}
module.exports = new Index()